home *** CD-ROM | disk | FTP | other *** search
- /*
- * Copyright (c) 1993 Michael D. Bayne.
- * All rights reserved.
- *
- * Please see the documentation accompanying the distribution for distribution
- * and disclaimer information.
- */
-
- #include <libraries/gadtools.h>
-
- #include <clib/exec_protos.h>
- #include <clib/intuition_protos.h>
- #include <clib/gadtools_protos.h>
-
- #include "/Garshnelib/Garshnelib_protos.h"
- #include "/Garshnelib/Garshnelib_pragmas.h"
-
- #include "Star.h"
- #include "Star_rev.h"
- #include "/main.h"
- #include "//defs.h"
-
- struct ModulePrefs
- {
- LONG Mode;
- LONG Stars;
- LONG Speed;
- };
-
- struct ModulePrefs nP;
- VOID *OldPrefs = 0L;
- STATIC const UBYTE VersTag[] = VERSTAG;
-
- int BT_SAVEClicked( VOID )
- {
- if( OldPrefs )
- {
- CopyMem( &nP, OldPrefs, sizeof( struct ModulePrefs ));
- SavePrefs( OldPrefs );
- OldPrefs = 0L;
- }
-
- return QUIT;
- }
-
- int BT_TESTClicked( VOID )
- {
- MessageServer( BM_SENDBLANK );
-
- return OK;
- }
-
- int BT_SCREENClicked( VOID )
- {
- ScreenModeRequest( StarWnd, &nP.Mode, 0L );
-
- return OK;
- }
-
- int BT_CANCELClicked( VOID )
- {
- OldPrefs = 0L;
-
- return QUIT;
- }
-
- int SL_STARSClicked( VOID )
- {
- nP.Stars = StarMsg.Code;
-
- return OK;
- }
-
- int SL_SPEEDClicked( VOID )
- {
- nP.Speed = StarMsg.Code;
-
- return OK;
- }
-
- #define BL_SetGadgetAttrs( Gad, Tag, Val ) GT_SetGadgetAttrs( StarGadgets[Gad], StarWnd, 0L, Tag, Val, TAG_END )
-
- int StarVanillaKey( VOID )
- {
- switch( StarMsg.Code ) {
- case 's':
- return BT_SAVEClicked();
- case 't':
- return BT_TESTClicked();
- case 'd':
- return BT_SCREENClicked();
- case 'c':
- return QUIT;
- case 'a':
- BL_SetGadgetAttrs( GD_SL_STARS, GTSL_Level, Inc( nP.Stars, 1, 150 ));
- return OK;
- case 'A':
- BL_SetGadgetAttrs( GD_SL_STARS, GTSL_Level, Dec( nP.Stars, 1, 10 ));
- return OK;
- case 'p':
- BL_SetGadgetAttrs( GD_SL_SPEED, GTSL_Level, Inc( nP.Speed, 1, 20 ));
- return OK;
- case 'P':
- BL_SetGadgetAttrs( GD_SL_SPEED, GTSL_Level, Dec( nP.Speed, 1, 2 ));
- return OK;
- default:
- return OK;
- }
- }
-
- VOID DoPrefs( LONG command, VOID *Prefs )
- {
- switch( command )
- {
- case STARTUP:
- OldPrefs = Prefs;
- CopyMem( Prefs, &nP, sizeof( struct ModulePrefs ));
- if( !SetupScreen())
- {
- StarLeft = ( Scr->Width - ComputeX( StarWidth ))/2 - Scr->WBorRight;
- StarTop = ( Scr->Height - ComputeY( StarHeight ) - Font->ta_YSize )/2 - Scr->WBorBottom;
- if( !OpenStarWindow())
- {
- BL_SetGadgetAttrs( GD_SL_STARS, GTSL_Level, nP.Stars );
- BL_SetGadgetAttrs( GD_SL_SPEED, GTSL_Level, nP.Speed );
- }
- CloseDownScreen();
- }
- break;
- case IDCMP:
- if( HandleStarIDCMP() != QUIT )
- break;
- case KILL:
- CloseStarWindow();
- break;
- }
- }
-
- LONG WndSignal( VOID )
- {
- return StarWnd ? 1L << StarWnd->UserPort->mp_SigBit : 0L;
- }
-
- VOID FillDefaults( VOID *Prefs )
- {
- struct ModulePrefs mPO = { 0L, 10L, 16 };
-
- mPO.Mode = getTopScreenMode();
- CopyMem( &mPO, Prefs, sizeof( struct ModulePrefs ));
- }
-